package view;
import java.io.*;

import observer.Observer;
import observer.Subject;

import model.VendingMachineModel;


public class VendingMachineView implements Observer {

  private VendingMachineModel model;
    
  public VendingMachineView(VendingMachineModel model) {
    this.model = model;
  }
  

public void printBalance(){    
    System.out.println(this.getBalanceString());
  }

  public void printDrinkPrice(){ 
    System.out.println( this.getDrinkPriceString() );
  }

  public void printErrorMessage() { 
	System.out.println( this.getErrorMessageString());
  }
  
  public int printInput() throws IOException{    

	BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
		System.out.print("(1)input 10 yen,  (2) input 100 yen , (3) buy juice, (4)exit ");
	
		String line = stdReader.readLine();
		return  Integer.parseInt(line);
  }

  public void outputDrink() {     
    System.out.println("[Juice]");
  }

  public void printOutput(){   
    System.out.println("Your Change is :" + model.getCoin() + "yen" );
  }
  
  public String getDrinkPriceString(){

	  return "Drink price is " + model.getDrinkPrice() + " yen";
  }
  
  public String getBalanceString(){
	 
	 return "Now balance is " + model.getCoin() + " yen";
  }
  
  public String getErrorMessageString(){
	  
	  return "Failed to buy drink because your input is less than drink price";
  }

@Override
public void update(Subject subject) {
	// TODO Auto-generated method stub
	this.printBalance();
}


@Override
public void setName(String string) {
	// TODO Auto-generated method stub
	
}


@Override
public String getName() {
	// TODO Auto-generated method stub
	return null;
}
  
  
}

